

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置我的密码</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">修改密码</div>
          <div class="layui-card-body" pad15>
            
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="oldcode" lay-verify="required" class="layui-input" placeholder="当前密码">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="code" lay-verify="required" autocomplete="off" class="layui-input" placeholder="设置新密码">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="code1" lay-verify="required" autocomplete="off" class="layui-input" placeholder="确认新密码">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit lay-filter="setmypass">确认修改</button>
                </div>
              </div>
            </div>
            
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="../../layuiadmin/layui/layui.js"></script>
  <script src="../../js/common.js"></script>
 <script>
 	layui.config({
 		base: '../../layuiadmin/' //静态资源所在路径
 	}).extend({
 		index: 'lib/index' //主入口模块
 	}).use(['index', 'user'], function() {
 		var $ = layui.$,
 			setter = layui.setter,
 			admin = layui.admin,
 			form = layui.form,
 			router = layui.router();
			form.render();
 
 		//找回密码下一步
 		form.on('submit(setmypass)', function(obj) {
 			var field = obj.field;
 			console.log(field);
			if($('input[name=code1]').val() != $('input[name=code]').val()){
				layer.msg('两次密码不一致');
			} else {
				submitdata(server.change_updatepassword,field)
			}
 
 			return false;
 		});
 
 		function submitdata(_url,_data) {
 			$.post(_url, _data, function(res, status) {
 				if (status == 'success') {
 					if (res.code == 0) {
 						layer.confirm('操作成功，是否重新登录？',{ btn: ['重新登录','取消'] }, function(){
							cookie.SetCookie('token', '', -1, domain, '/')
							cookie.SetCookie('uid', '', -1, domain, '/')
							cookie.SetCookie('memberid', '', -1, domain, '/')
							
							cookie.SetCookie('token', '', -1)
							cookie.SetCookie('uid', '', -1)
							cookie.SetCookie('memberid', '', -1)
							
							parent.location.href = '../login.html';
 						}, function(){
//							layer.msg('取消操作');
							cookie.SetCookie('token', '', -1, domain, '/')
							cookie.SetCookie('uid', '', -1, domain, '/')
							cookie.SetCookie('memberid', '', -1, domain, '/')
							
							cookie.SetCookie('token', '', -1)
							cookie.SetCookie('uid', '', -1)
							cookie.SetCookie('memberid', '', -1)
							
							parent.location.href = '../login.html';
 						});
 					} else {
 						layer.msg(res.msg);
 					}
 					closeloading();
 				} else {
 					closeloading();
 					layer.msg('服务器连接错误');
 				}
 			});
 		}
 
 	});
 </script>
</body>
</html>